home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / VS_804.ARJ / MAINTSRC.EXE / R_FIELDS.PRG < prev    next >
Text File  |  1991-10-19  |  2KB  |  84 lines

  1. * Filename......: R_Fields.Prg
  2. *
  3. * Author........: Vernon E. Six, Jr.
  4. *
  5. * Last Update...: Sat  10-19-1991  21:56:00
  6. *
  7. * Notice........: Copyright (c) 1991 by Vernon E. Six, Jr.
  8. *                 All Rights Reserved World Wide
  9. *
  10. * Dialect.......: Clipper v5.0x
  11.  
  12.  
  13. #include "SETCURS.CH"
  14. #include "INKEY.CH"
  15.  
  16. FUNCTION R_Fields()
  17. *****
  18. * Renumber the fields in a database
  19. *****
  20. LOCAL ac_Fields  := {}
  21. LOCAL n_Cntr     := 0
  22.  
  23.  
  24.    VS_Text( 2, "", PADC("Renumber...",40), "" )
  25.  
  26.  
  27.       *****
  28.       * Read all the fields into an array
  29.       *****
  30.       _DICTFLD->( dbSeek( _DICTHDR->DBF_NAME ) )
  31.  
  32.       DO WHILE .NOT. _DICTFLD->(EOF())
  33.  
  34.          IF _DICTFLD->DBF_NAME <> _DICTHDR->DBF_NAME
  35.             EXIT
  36.          ENDIF
  37.  
  38.          AADD( ac_Fields, _DICTFLD->FIELD_NAME )
  39.  
  40.          _DICTFLD->( dbSkip() )
  41.  
  42.       ENDDO
  43.  
  44.  
  45.       *****
  46.       * Change the index order to something we aren't going to be
  47.       * changing... i.e. field name (since we have that in an array anyway)
  48.       *****
  49.       _DICTFLD->( dbSetOrder(2) )
  50.  
  51.  
  52.       *****
  53.       * Step through the array and change the number as we go
  54.       *****
  55.       FOR n_Cntr = 1 TO LEN( ac_Fields )
  56.  
  57.          IF _DICTFLD->( dbSeek( _DICTHDR->DBF_NAME + ac_Fields[n_Cntr] ) )
  58.  
  59.             IF _DICTFLD->( VS_RLock() )
  60.  
  61.                REPLACE _DICTFLD->FIELD_NMBR  WITH STRZERO(n_Cntr*5,3,0)
  62.  
  63.                _DICTFLD->( dbUnlock() )
  64.  
  65.             ENDIF
  66.  
  67.          ENDIF
  68.  
  69.       NEXT n_Cntr
  70.  
  71.  
  72.       *****
  73.       * Set it back the way it was
  74.       *****
  75.       _DICTFLD->( dbSetOrder(1) )
  76.  
  77.    VS_EndText()
  78.  
  79. RETURN(NIL)
  80. *** EOF: R_Fields() *********************************************************
  81.  
  82.  
  83.  
  84.